package com.example.support.controller;

import com.example.support.domain.ShoppingBill;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: xwg
 * @CreateDate: 2023/10/7
 */

@RestController
@RequestMapping("/testing")
public class TestingController {
    @Value("${server.port}")
    private String port;

    @GetMapping("/time")
    public String time(HttpServletRequest request) {
        String token = request.getHeader("token");
        System.out.println(" token=" + token);
        return port + " : " + System.currentTimeMillis();
    }

    @PostMapping("/insert")
    public ShoppingBill insert(@RequestBody ShoppingBill shoppingBill) {
        shoppingBill.setBillCode(System.currentTimeMillis() + "||" + port);
//      save into db
        return shoppingBill;
    }
}
